Skip to content

Conversation

@batjko
Copy link
Owner

@batjko batjko commented Jan 27, 2026

Summary

Addresses #14 - "This ain't got no tests!"

This PR adds comprehensive test coverage for the books functionality, which was previously untested.

New Tests Added (8 tests)

Resolver Structure

  • Validates that all expected resolver functions exist (books, book, addBook)

Query Tests

  • books query returns an array
  • books query returns books with correct structure (id, title, author)
  • book(id) query returns a single book by ID
  • book(id) query returns null for non-existent ID
  • Field selection is respected (only requested fields returned)

Mutation Tests

  • addBook mutation creates a new book with correct data
  • Created books can be retrieved via book(id) query

Test Results

18 tests passed (was 10)

Test Plan

  • All existing tests still pass
  • New tests cover queries, mutations, and edge cases
  • Tests clean up after themselves (disconnect DB client)

Closes #14

Adds 8 new tests for the books functionality:
- Resolver structure validation
- books query (returns array, correct structure, field selection)
- book(id) query (single book, non-existent id returns null)
- addBook mutation (creates book, created book can be retrieved)

Total test count: 18 (was 10)

Closes #14
- Update node.js.yml to test on Node 20.x and 22.x (required by Apollo Server 5 and Prisma 7)
- Add npm cache for faster CI
- Add prisma generate step before tests
- Update actions/checkout and actions/setup-node to v4
- Update codeql-action to v3
@batjko batjko merged commit f8bccc7 into master Jan 27, 2026
4 checks passed
@batjko batjko deleted the add-book-tests branch January 27, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

This ain't got no tests!

2 participants